import {LocalStorageUtils} from '@/utils/tyutils'

const state = {
    mapAddress: undefined
}
const mutations = {
    setMapAddress(state: any, mapUrl: any) {
        try {
            state.mapAddress = mapUrl
            LocalStorageUtils.setItem({
                name: "mapUrl",
                value: mapUrl,
                expires: 720
            })
        } catch (err) {
            console.log(err.toString())
        }

    }
}

const actions = {
    setMapAddress(context: any, mapUrl: any){
        context.commit("setMapAddress",mapUrl)
    },
}

const getters = {
    getMapAddress:(state: any)=>{
        let result = LocalStorageUtils.getItem("mapUrl")
        if(!result) return false
        state.mapAddress = result
       return result
    }
}
export default {
    namespaced:true,
    state: state,
    mutations: mutations,
    actions: actions,
    getters: getters
}
